#!/usr/bin/python
# -*- coding: utf-8 -*-

# limit the VM heap
def alloc(src, hard):
    import resource
    resource.setrlimit(resource.RLIMIT_DATA, (src, hard))

# Log to a text file
def log(txt, name):
    import logging
    # log the program to see how slow it is
    logger = logging.getLogger(name)
    fh = logging.FileHandler(txt)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    fh.setFormatter(formatter)
    logger.setLevel(logging.INFO)
    logger.addHandler(fh)
    return logger

